{% include 'QLGL/QLGL_index.html' %}

<div class="am-cf admin-main">
  {% include 'sidebar.html' %}
  <!-- content start -->
  <div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">字典数据>部件权重</strong></div>
      </div>
      <div class="am-g" style="position: absolute;height: 100%;right: 0px;left: 260px;width: auto;">

        {% include 'QLGL/ZDSJ/QLGL_ZDSJ_SIDEBAR.html' %}
        <div class="am-u-sm-10" style="position: absolute;width:auto;right:0;left: 200px;overflow-y: scroll;bottom: 200px;top: 0;">
          <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
              <div class="am-btn-group am-btn-group-xs">
                <button style="margin: 0 5px" type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="back_to()">返回</button>
                <button style="margin: 0 5px" type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="rule_add({{ parts_sub_id }})"><span class="am-icon-plus"></span>新增</button>
              </div>
            </div>
          </div>
          <div class="am-u-sm-12 am-u-md-12">
            <div style="padding: 15px;">
              子部件名称：<strong>{{ subPartInfo.parts_sub_name }}</strong>
            </div>
          </div>

          <table id="grid_sub_see" class="am-table am-table-striped am-table-hover table-main am-table-compact " style="width: 100%">
            <thead>
              <tr>
                <th class="table-title">模板</th>
                <th class="table-title">变参</th>
                <th class="table-title">编号</th>
                <th class="table-title">名称</th>
                <th class="table-title">备注</th>
                <th class="table-title">操作</th>
              </tr>
            </thead>
            <tbody>
              {% for i in subPartRuleList %}
              <tr>
                <td>
                {% if i.position == 1 %}
                {{ positionInfo.1 }}
                {% elif i.position == 2 %}
                {{ positionInfo.2 }}
                {% elif i.position == 3 %}
                {{ positionInfo.3 }}
                {% endif %}
                </td>
                <td>{{ i.param_num }}</td>
                <td>{{ i.parts_num }}</td>
                <td>{{ i.parts_note }}</td>
                <td>{{ i.remark }}</td>
                <td>
                  <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs"><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="rule_modify({{ i.parts_sub_rule_id }})"><span class="am-icon-pencil-square-o"></span> 修改</button><button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="rule_delect({{ i.parts_sub_rule_id }},{{ i.param_num }})"><span class="am-icon-trash-o"></span> 删除</button></div>
                  </div>
                </td>
              </tr>
              {% endfor %}
            </tbody>
          </table>

        </div>
      </div>
    </div>
  </div>
</div>
{% include 'footer.html' %}
<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/static/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="/static/assets/js/amazeui.min.js"></script>
<script src="/static/assets/js/amazeui.tree.js"></script>
<script type="text/javascript" src="/static/assets/js/layer.js"></script>
<script src="/static/assets/datatables/amazeui.datatables.min.js"></script>
<script src="/static/assets/dialog/amazeui.dialog.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/assets/css/amazeui.tree.css" />
<script src="/static/assets/js/app.js"></script>
<style type="text/css">
  .li_a {
    color: #5c5c5c;
  }
</style>
<script type="text/javascript">
  $("#collapse-nav1").addClass("am-in");
  $("#qlgl").removeClass("am-collapsed");
  $("#qlglOzdsj").css("color", "#3399CC");
  $("#qlgl").css("color", "#3399CC");
  $("#zdsjObjqz").removeClass("li_a");
</script>
<script type="text/javascript">
  // var bridge_type = {{ bridge_type|safe }};
  // var parts_code = {{ parts_code|safe }};
  // var bridgeTypeName = {{ bridgeTypeName|safe }};
  // var partsName = {{ partsName|safe }};

  function back_to() {
    window.history.back(-1);
  }

  function rule_add(parts_sub_id) {
    // window.location.href="/QLXJ_XJYW_DQJC_DISEASE_MOVE/?check_record_id="+check_record_id+""
    popup("新增规则", "/QLXJ_QLLB_ZBJGZ_RULE_ADD/?parts_sub_id=" + parts_sub_id + "")
  }

  function rule_modify(parts_sub_rule_id) {
    popup("修改规则", "/QLXJ_QLLB_ZBJGZ_RULE_MOD/?parts_sub_rule_id=" + parts_sub_rule_id + "")
  }

  function rule_delect(parts_sub_rule_id, param_num) {
    AMUI.dialog.confirm({
      title: '删除确认',
      content: '您确认删除变参为：[' + param_num + ']的规则?',
      onConfirm: function() {
        //console.log('onConfirm,save ' + organize_id);
        $.ajax({
          "url": "/QLXJ_QLLB_ZBJGZ_RULE_DELSAVE/",
          "data": {
            "parts_sub_rule_id": parts_sub_rule_id
          },
          "datatype": "json",
          "type": "post",
          "async": "false"
        }).success(function(data) {
          if(data.status == 1) {
            window.location.reload();
          } else {
            AlertMSG(data.message)
          }
        }).error(function(data) {
          AlertMSG("删除失败！")
        });
      },
      onCancel: function() {
        console.log('onCancel')
      }
    });
  }

  var AlertMSG = function(msg) {
    AMUI.dialog.alert({
      title: '错误提示',
      content: msg,
      onConfirm: function() {
        console.log('close');
      }
    });
  }
  $.ajaxSetup({
    data: {
      csrfmiddlewaretoken: '{{ csrf_token }}'
    },
  });

  function popup(title, url) {
    var index = layer.open({
      type: 2,
      title: title,
      content: url,
      area: ['600px', '500px'],

    });
  }
</script>
</body>

</html>